


//________________  Author : GEORGE FLOROS [GR] ___________ 06.08.18 _____________

/*
________________ GF Blood Stains and SFX LITE Script ________________

https://forums.bohemia.net/forums/topic/218538-gf-blood-stains-and-sfx-lite-script/

Please keep the Credits or add them to your Diary

https://community.bistudio.com/wiki/SQF_syntax
Don't try to open this with the simple notepad.
For everything that is with comment  //  in front  or between /* 
means that it is disabled , so there is no need to delete the extra lines. 

You can open this ex:
with notepad++
https://notepad-plus-plus.org/

and also use the extra pluggins
(this way will be better , it will give also some certain colours to be able to detect ex. problems )
http://www.armaholic.com/page.php?id=8680

or use any other program for editing .

For the Compilation List of my GF Scripts , you can search in:
https://forums.bohemia.net/forums/topic/215850-compilation-list-of-my-gf-scripts/

WARNING!!!
This AddOn increases seriously the gore factor in ArmA.
It is not recommended for use by children under the age of 15 years.
*/
gf_blood_shot_list = [	
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Shot\2_Blood_Shot.paa",	
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Shot\6_Blood_Shot.paa",
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Shot\8_Blood_Shot.paa",
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Shot\9_Blood_Shot.paa",
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Shot\10_Blood_Shot.paa",
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Shot\11_Blood_Shot.paa",
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Shot\12_Blood_Shot.paa",
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Shot\13_Blood_Shot.paa",
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Shot\14_Blood_Shot.paa",						
			
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Spray\3_Blood_Spray.paa",	
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Spray\8_Blood_Spray.paa",
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Spray\9_Blood_Spray.paa",
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Spray\13_Blood_Spray.paa",				
	"GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Blood_Shot_images_1024\GF_Blood_Spray\15_Blood_Spray.paa"	
];

diag_log "//________________ GF_Blood_Shot Script _____________";

//systemchat "GF_Blood_Shot Script    I n i t i a l i z e d";
  
GF_Set_Blood_Shot = { 
_this addEventHandler ["hitPart", {

	 	_target    = (_this select 0) select 0;
	 	_shooter   = (_this select 0) select 2;
				
		_target setBleedingRemaining 0;          
	
		

//________________ Images  _____________
		
_Blood_Shot_List = selectRandom gf_blood_shot_list;
			
			
_Pos_shooter = eyePos _shooter;
_end_Pos = positionCameraToWorld [0,0,1000];
_end_PosASL = AGLToASL _end_Pos;			


_GF_lineIntersectsSurfaces = lineIntersectsSurfaces [	
	_Pos_shooter,
	_end_PosASL,		
	_target,
    objNull,
	true,
	1,
	"VIEW",
	"NONE"
	];
if (count _GF_lineIntersectsSurfaces == 0) exitWith {
		//_Blood_Shot_Normal_ORANGE_DLC setPos [0,0,0]
};			

//只相交 地面和 建筑
_lis = _GF_lineIntersectsSurfaces select 0;
_obj = _lis select 2;

//不为空并且不为建筑
if(!(isNull _obj) && {!(_obj isKindOf "Building")}) exitWith{};

//	hintSilent str _GF_lineIntersectsSurfaces;			
//交点沿着 点到射击者 移动一点距离
#define DT 0.01
#define MIN 0.0001
_vector_pos = _lis select 0;

//systemChat str (_vector_pos distanceSqr _target);
//systemChat str _vector_pos;
//systemChat str (getPos _target);

//sqr 考虑了z值，是错误的
if(_vector_pos distance2D _target > 3) exitWith{};


_vector_dir = vectorNormalized (_Pos_shooter vectorDiff _vector_pos);
_vector_pos = _vector_pos vectorAdd (_vector_dir vectorMultiply ((random DT) + MIN));

/*
//坐标随机偏移一点防止重叠
#define DT 0.05
_vector_pos = _GF_lineIntersectsSurfaces select 0;
_vector_pos = [_vector_pos select 0 + random DT,_vector_pos select 1 + random DT,_vector_pos select 2 + random DT];
_GF_lineIntersectsSurfaces set [0,_vector_pos];
*/

/*		
if (true) then {	
			
_Blood_Shot_Normal = "VR_GroundIcon_01_F" createVehicle [0,0,0];
_Blood_Shot_Normal setObjectTexture [0,_Blood_Shot_List];
_Blood_Shot_Normal setDir random 360;

_Blood_Shot_Normal setPosASL (_GF_lineIntersectsSurfaces select 0 select 0); 
_Blood_Shot_Normal setVectorUp (_GF_lineIntersectsSurfaces select 0 select 1);			
			
};
*/			
			
/*
_Blood_Shot_Normal_ORANGE_DLC = "BloodSplatter_01_Small_New_F" createVehicle [0,0,0];
_Blood_Shot_Normal_ORANGE_DLC setObjectTexture [0,_Blood_Shot_List];
_Blood_Shot_Normal_ORANGE_DLC setDir random 360;

_Blood_Shot_Normal_ORANGE_DLC setPosASL _vector_pos; 
_Blood_Shot_Normal_ORANGE_DLC setVectorUp _vector_normal;
*/

//爆头血多一些
_type = "BloodSplatter_01_Small_New_F";
if("head" in (_this select 0 select 5))then {_type = "BloodSplatter_01_Large_New_F"};

//简单对象，本对象是全局的
_Blood_Shot_Normal_ORANGE_DLC = createSimpleObject [_type, _vector_pos];//BloodSplatter_01_Small_New_F  BloodSplatter_01_Large_New_F
_Blood_Shot_Normal_ORANGE_DLC setObjectTexture [0,_Blood_Shot_List];
_Blood_Shot_Normal_ORANGE_DLC setDir (random 360);
_Blood_Shot_Normal_ORANGE_DLC setVectorUp (_lis select 1);
/*
if (true) then {

_Blood_Shot_Large_ORANGE_DLC = "BloodSplatter_01_Large_New_F" createVehicle [0,0,0];
_Blood_Shot_Large_ORANGE_DLC setObjectTexture [0,_Blood_Shot_List];
_Blood_Shot_Large_ORANGE_DLC setDir random 360;

_Blood_Shot_Large_ORANGE_DLC setPosASL (_GF_lineIntersectsSurfaces select 0 select 0); 
_Blood_Shot_Large_ORANGE_DLC setVectorUp (_GF_lineIntersectsSurfaces select 0 select 1);

};
*/

/*
//________________ _1__CHECK_Surfaces test _____________		
if (_4_Test_Surfaces) then {	
	
	_CHECK_Surfaces = "BloodSplatter_01_Small_New_F" createVehicle [0,0,0];
	onEachFrame {
	_ins_Test = lineIntersectsSurfaces [
		AGLToASL positionCameraToWorld [0,0,0], 
		AGLToASL positionCameraToWorld [0,0,1000], 
		player
	];
	if (count _ins_Test == 0) exitWith {_CHECK_Surfaces setPosASL [0,0,0]};
	_CHECK_Surfaces setPosASL (_ins_Test select 0 select 0); 
	_CHECK_Surfaces setVectorUp (_ins_Test select 0 select 1);
	
	//	hintSilent str _ins_Test;
	};
	
};	
*/


}];};

/*
[] spawn {
	while {true} do {
    _time = diag_tickTime + 1;
    _i = 0;
    waitUntil {
	sleep 2;
        _i = _i + 1;		
        diag_tickTime >= _time
    };	
    //	hint format ["Code executed %1 times per second", _i];
	
	{	
		if (((alive _x)) && (!(_x getVariable ["EΗ_GF_Set_Blood_Shot",false]))) then {
			_x call GF_Set_Blood_Shot};						
			_x setVariable ["EΗ_GF_Set_Blood_Shot",true];	

			{waitUntil {!alive _x};
			_x setVariable ["EΗ_GF_Set_Blood_Shot",false];		 
		};
	}forEach allUnits;	

	};
};
*/